Open Bug 1701546 Opened 4 years ago Updated 3 years ago

window.mozInnerScreenX for in-process iframe documents need to factor the desktop zoom value

Categories

(Core :: Layout, defect)

Unspecified
Android
defect

Tracking

()

People

(Reporter: m_kato, Unassigned)

References

Details

I found this issue when I investigated bug 1700365.

To calculate mozInnerScreenX and mozInnerScreenY, DOM uses nsIFrame::GetScreenRectInAppUnits. But If no rootFrameParent, we use nsIWidget::WidgetToScreenOffset to get screen x and y position.

When using mobile view port, mozInnerScreenX and mozInnerScreenY have strange value. Although window.top.mozInnerScreenX isn't apply zoom resolution, window.mozInnerScreenX in <iframe> apply zoom resolution incompletely. Calculating valid screen x in iframe seems to become the following in GeckoView.

window.top.mozInnerScreenX + (window.mozInnerScreenX - window.top.mozInnerScreenX) * nsIDOMWindowUtils(window.top).getResolution()

Should window.top.mozInnerScreenX apply the resolution of mobile viewport?

Also, APZ test has a hack as https://searchfox.org/mozilla-central/rev/cc9d803f98625175ed20111d9736e77f3d430cd5/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js#305-321 for this issue.

Ikezoe-san, is this known issue of mobile view port?

Flags: needinfo?(hikezoe.birchill)

Can you please clarify what the strange value is? mozInnerScreenX is value in the screen coords, it shouldn't be affected by the zoom value. For example, if the value is (100, 100), then the value is always (100, 100) regardless of what the zoom value is.

The code you referred is about device pixel ratio, not zoom value as far as I can tell.

Flags: needinfo?(hikezoe.birchill) → needinfo?(m_kato)

viewport initial-scale=1

https://makotokato.github.io/bugs/mozinner-1.html

viewport initial-scale=0.5

https://makotokato.github.io/bugs/mozinner-2.html

Although window.top.mozInnerscreenX/Y is screen coordinates, but iframe's window.mozInnerscreenX/Y isn't screen coordinate (window.top.mozInnerScreen(X|Y) + (window.mozInnerScreen(X|Y) - window.top.mozInnerScreen(X|Y)) * nsIDOMWindowUtils(window.top).getResolution() seems to be screen coordinate).

Flags: needinfo?(m_kato)
Flags: needinfo?(hikezoe.birchill)

I am changing this bug title to reflect what the problem is (I guess, I don't yet understand the problem though).

To me, on Android emulator with GeckoView example (which is a bit old version of the one), both cases look same;

window.top.mozInnerScreenX: 0
window.top.mozInnerScreenY: 24
window.mozInnerScreenX: 10
window.mozInnerScreenY: 134

I don't yet understand what the problem is. To me those value are correct. So for example, the mozInnerScreenY for the iframe window, it's positioned at (0px, 100px) and the body margin of the parent window is (8px, 8px), and the iframe's border is (probably) 2px.

What values are you seeing on your device?

Flags: needinfo?(hikezoe.birchill)
OS: Unspecified → Android
Summary: window.top.mozInnerScreenX and window.mozInnerScreenX are different coordinates. → window.mozInnerScreenX for iframe documents seems to be wrong.

If this value is screen coordinate, this value (iframe's window.mozInnerScreenX/Y) should changed via viewport scale since content's scale isn't 1 and rendered position of iframe isn't same.

window.top.mozInnerScreenX/Y should keep same value even if resolution is changed, if this is screen coordinate

Oh now I see what you meant. (I was confused by the different word in the title. :/)

Anyway, I hadn't been aware of this issue. That said, I think the value is probably wrong in transformed iframes. There is a bug about the transformed iframe case (bug 1691346). And I Assume this should work in Fission.

See Also: → 1691346
Summary: window.mozInnerScreenX for iframe documents seems to be wrong. → window.mozInnerScreenX for in-process iframe documents need to factor the desktop zoom value
Severity: -- → S3
You need to log in before you can comment on or make changes to this bug.